import React from "react";

import { Route, Switch } from "react-router-dom";

// 引入页面
import loadable from "react-loadable";
import Loading from "components/Loading";

const Home = loadable({
  loader: () => import("pages/home"),
  loading: Loading,
  timeout: 10000 // 10seconds
});
const Realtime = loadable({
  loader: () => import("pages/vehicle/realtime"),
  loading: Loading,
  timeout: 10000 // 10seconds
});
const Searcharea = loadable({
  loader: () => import("pages/vehicle/search-area"),
  loading: Loading,
  timeout: 10000 // 10seconds
});
const PlatformAssessment = loadable({
  loader: () => import("pages/assessment/PlatformAssessment"),
  loading: Loading,
  timeout: 10000 // 10seconds
});
const PlatformStatistics = loadable({
  loader: () => import("pages/statistics/PlatformStatistics"),
  loading: Loading,
  timeout: 10000 // 10seconds
});
const Page = loadable({
  loader: () => import("pages/page"),
  loading: Loading,
  timeout: 10000 // 10seconds
});
const Counter = loadable({
  loader: () => import("pages/counter"),
  loading: Loading,
  timeout: 10000 // 10seconds
});
const NotFound = loadable({
  loader: () => import("pages/notfound"),
  loading: Loading,
  timeout: 10000 // 10seconds
});
const UserInfo = loadable({
  loader: () => import("pages/userInfo"),
  loading: Loading,
  timeout: 10000 // 10seconds
});

// 路由
const getRouter = () => (
  <Switch>
    <Route exact path="/" component={Home} />
    <Route path="/realtime" component={Realtime} />
    <Route path="/searcharea" component={Searcharea} />
    <Route path="/platformassessment" component={PlatformAssessment} />
    <Route path="/platformstatistics" component={PlatformStatistics} />
    <Route path="/page" component={Page} />
    <Route path="/counter" component={Counter} />
    <Route path="/userinfo" component={UserInfo} />
    <Route component={NotFound} />
  </Switch>
);

export default getRouter;
